{extend name="base:base" /}
{block name="body"}

<div class="layui-container form-box">  

    <div class="layui-tab layui-tab-brief">
        <ul class="layui-tab-title">
            <li class="layui-this">状态跟踪</li>
            <li>商品列表</li>
            <li>订单详情</li>            
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">


                <table lay-even="" class="layui-table">
                    <thead>
                        <tr>
                            <td><b>时间</b></td>
                            <td><b>订单附言</b></td>
                            <td><b>状态</b></td>
                            <td><b>操作</b></td>
                        </tr>
                    </thead>
                    <tbody>
                        <?php foreach ($order_history_lists as $key => $value) { ?>
                            <tr>
                                <td><?php echo $value['create_time']; ?></td>
                                <td><?php echo $value['remark']; ?></td>
                                <td><?php echo $value['order_status_text']; ?></td>
                                <td>
                                    <a href="<?php echo url('order_history_delete', ['id' => $value['id']]) ?>" class="ajax-get confirm layui-btn layui-btn-xs layui-btn-danger">删除</a>

                                </td>
                            </tr>
                        <?php } ?>
                    </tbody>
                </table>



                <form class="layui-form form-box" action="<?php echo url('order_history_update'); ?>" method="post">
                    <input type="hidden" name="id" value="{$Think.get.id}" />
                    <table class="layui-table">
                        <tbody>
                            <tr>
                                <th>订单状态</th>
                                <td>
                                    <input type="hidden" name="old_status" value="<?php echo $status; ?>" id="old_status" />
                                    <div class="layui-input-inline">
                                        <select name="status"  lay-filter="status">
                                            <?php echo html_select($status_select, $status); ?>
                                        </select>
                                    </div>
                                </td>
                            </tr>
                            <tr class="express_tr" <?php
                            if ($status != 30) {
                                echo 'style="display: none;"';
                            }
                            ?>>
                                <td>快递公司</td>
                                <td>
                                    <div class="layui-input-inline">
                                        <select name="express_id">
                                            <option value="">=请选择=</option>
                                            <?php echo html_select($express_select, $express_id); ?>
                                        </select>
                                    </div>
                                    单号  
                                    <div class="layui-input-inline">
                                        <input type="text" class="layui-input"  name="express_number" value="<?php echo $express_number; ?>" />
                                    </div>
                                </td>
                            </tr>

                            <tr>
                                <td>订单附言</td>
                                <td><input type="text"  class="layui-input" name="remark" />
                                </td>
                            </tr>
                            <tr>
                                <td></td>
                                <td>
                                    <button id="button-history" class="layui-btn layui-btn-normal" lay-filter="myform" lay-submit>
                                        <i class="fa fa-plus-circle"></i>
                                        添加订单记录
                                    </button>
                                </td>
                            </tr>

                        </tbody>
                    </table>
                </form>

            </div>
            <div class="layui-tab-item">

                <table lay-even="" class="layui-table">
                    <thead>
                        <tr>
                            <td>商品品名</td>
                            <td>图片</td>
                            <td class="right">数量</td>
                            <td class="right">价格</td>              
                            <td class="right">总计</td>
                        </tr>
                    </thead>
                    <tbody>
                        <?php
                        $sum = 0;
                        foreach ($goods_lists as $key => $value) {
                            $sum += $value['quantity'] * $value['price'];

                            $goods = json_decode($value['goods_data'], true);
                            ?>
                            <tr>
                                <td>
                                    <?php echo $goods['title']; ?>
                                </td>
                                <td>
                                    <img src="<?php echo $goods['image']; ?>" />
                                </td>
                                <td class="right">	              	
                                    <?php echo $value['quantity']; ?>              </td>
                                <td class="right">￥
                                    <?php echo $value['price']; ?>	              </td>
                                <td class="right">￥<?php echo $value['total']; ?></td>
                            </tr>
                        <?php } ?>
                        <tr>
                            <td colspan="4" class="text-right">总价:</td>
                            <td class="right">￥ <?php echo sprintf('%.2f', $sum); ?></td>
                        </tr>
                    </tbody>
                </table>

            </div>
            <div class="layui-tab-item">


                <table lay-even="" class="layui-table">
                    <tbody><tr>
                            <td>订单编号</td>
                            <td><?php echo $order_number; ?></td>
                        </tr>
                        <tr>
                            <td>备注</td>
                            <td><?php echo $remark; ?></td>
                        </tr>

                        <tr>
                            <td>收货人</td>
                            <td>
                                <?php echo $receiver; ?>
                            </td>
                        </tr> 
                        <tr>
                            <td>收货地址</td>
                            <td>
                                <?php echo $receiver_address; ?>
                            </td>
                        </tr>                          
                        <tr>
                            <td>合计金额</td>
                            <td>
                                ￥ <?php echo $total; ?>			    </td>
                        </tr>

                        <tr>
                            <td>下单时间</td>
                            <td> <?php echo $create_time; ?> </td>
                        </tr>
                        <tr>
                            <td>IP地址</td>
                            <td><?php echo $ip; ?></td>
                        </tr>  
                        <tr>
                            <td>用户系统</td>
                            <td ><?php echo str_replace(' ', '<br />', $user_agent); ?></td>
                        </tr>
                    </tbody>
                </table>



            </div>
        </div>
    </div>


</div>


{/block}
{block name="foot_js"}
<script>


    layui.use(['jquery', 'form', 'upload'], function () {  //如果只加载一个模块，可以不填数组。如：layui.use('form')
        var $ = layui.$
                , form = layui.form //获取form模块
                , upload = layui.upload; //获取upload模块

        //监听提交按钮
        form.on('select(status)', function (data) {
            if ('30' == data.value) {
                $('.express_tr').show();
            } else {
                $('.express_tr').hide();
            }
        });

    });




//
//
//    $("select[name='status']").change(function () {
//        if ('3' == $(this).val()) {
//            $('.express_tr').show();
//        } else {
//            $('.express_tr').hide();
//        }
//    });
</script>
{/block}